package service;

import java.sql.Date;
import java.util.List;

import base.Service;
import bean.Institution;

public class InstitutionS extends Service
{
	public void saveInstitution(Institution ins)
	{
		String updateSql="update institution set istop='"+new Date(System.currentTimeMillis())+"' where iid=(select max(iid) from institution)"; 
		String insertSql="insert into institution(ifirston,ifirstoff,isecondon,isecondoff,ifirstlater,ifirstbefore,isecondlater,isecondbefore,iholiday,iforfeit,iallowMinute,imoneyminute,iallowtimes,istart,iattbonus ) values ( "
                            			+"'"+ins.getFirston()+
                                       "','"+ins.getFirstoff()+
                                       "','"+ins.getSecondon()+
                                       "','"+ins.getSecondoff()+
                                       "', "+ins.getFirstlater()+
                                       " , "+ins.getFirstbefore()+
                                       " , "+ins.getSecondlater()+
                                       " , "+ins.getSecondbefore()+
                                       " ,'"+ins.getHoliday()+
                                       "', "+ins.getForfeit()+
                                       " , "+ins.getAllowminute()+
                                       " , "+ins.getMoneyminute()+
                                       " , "+ins.getAllowtimes()+
                                       " ,'"+ins.getStart()+
                                       "', "+ins.getAttbonus()+")";
	     jdbc.execute(updateSql);
		 jdbc.execute(insertSql);
	}
    public List getInstitution()
    {
    	String sql="select * from institution where iid=(select max(iid) from institution)";
    	return jdbc.queryForList(sql);
    }
}